'use strict';

var app = angular.module('app', [
    'ngAnimate',
    'ngCookies',
    'ngResource',
    'ngSanitize',
    'ngTouch',
    'ngStorage',
    'ui.select',
    'toaster',
    'ui.router',
    'ui.bootstrap',
    'ui.load',
    'dbUtils',
    'ui.components.form.grid',
    'ui.jq',
    'ui.validate',
    'oc.lazyLoad',  
    'pascalprecht.translate',
    'rzModule'
]);

app.run(
    [          '$rootScope', '$state', '$stateParams',
        function ($rootScope,   $state,   $stateParams) {
            $rootScope.$state = $state;   //方便获取状态
            $rootScope.$stateParams = $stateParams;    //方便获取状态
        }
    ]
);


app.config(
    [          '$stateProvider', '$urlRouterProvider',
        function ($stateProvider,   $urlRouterProvider) {

            $urlRouterProvider
                .otherwise('/paas/mysql');

            $stateProvider

                .state('signin', {
                    url: '/signin',
                    templateUrl: 'tpl/page_signin.html',
                    controller:'SignCtrl',
                    resolve: {
                        deps: ['$ocLazyLoad',
                            function( $ocLazyLoad){
                                return $ocLazyLoad.load(['js/controllers/SignCtrl.js']);
                            }]
                    }
                })

                .state('paas', {
                    url: '/paas',
                    templateUrl: 'tpl/main.html'
                })

                //.state('app.paas', {
                //    url: '/paas',
                //    templateUrl: 'tpl/content.html'
                //})

                .state('paas.mysql', {
                    url: '/mysql',
                    templateUrl: 'tpl/paas/paas_mysql.html',
                    controller:'PaasMysqlCtrl',
                    resolve: {
                        deps: ['$ocLazyLoad',
                            function( $ocLazyLoad){
                                return $ocLazyLoad.load(['js/controllers/PaasMysqlCtrl.js']);
                            }]
                    }
                })

                .state('paas.mysqlDetail', {
                    url: '/mysqlDetail/:mysqlName',
                    templateUrl: 'tpl/mysqlDetail.html',
                    controller:'AsideFoldCtrl',
                    resolve: {
                        deps: ['$ocLazyLoad',
                            function( $ocLazyLoad){
                                return $ocLazyLoad.load(['js/controllers/AsideFoldCtrl.js']);
                            }]
                    }
                })


                .state('paas.mysqlDetail.basicInfo', {
                    url: '/basicInfo',
                    templateUrl: 'tpl/paas/basicInfo.html',
                    controller:'BasicInfoCtrl',
                    resolve: {
                        deps: ['$ocLazyLoad',
                            function( $ocLazyLoad){
                                return $ocLazyLoad.load(['js/controllers/BasicInfoCtrl.js']);
                            }]
                    }
                })

                .state('paas.mysqlDetail.accountManage', {
                    url: '/accountManage',
                    templateUrl: 'tpl/paas/accountManage.html',
                    controller:'AccountManageCtrl',
                    resolve: {
                        deps: ['$ocLazyLoad',
                            function( $ocLazyLoad){
                                return $ocLazyLoad.load(['js/controllers/AccountManageCtrl.js']);
                            }]
                    }
                })

                .state('paas.mysqlDetail.databaseManage', {
                    url: '/databaseManage',
                    templateUrl: 'tpl/paas/databaseManage.html',
                    controller:'DatabaseManageCtrl',
                    resolve: {
                        deps: ['$ocLazyLoad',
                            function( $ocLazyLoad){
                                return $ocLazyLoad.load(['js/controllers/DatabaseManageCtrl.js','js/controllers/CreateDatabaseCtrl.js']);
                            }]
                    }
                })

                .state('paas.mysqlDetail.databaseConect', {
                    url: '/databaseConect',
                    templateUrl: 'tpl/paas/formwizard.html'
                })

                .state('paas.mysqlDetail.monitorAlarm', {
                    url: '/monitorAlarm',
                    templateUrl: 'tpl/paas/monitorAlarm.html',
                    controller:'MonitorAlarmCtrl',
                    resolve: {
                        deps: ['$ocLazyLoad',
                            function( $ocLazyLoad){
                                return $ocLazyLoad.load(['js/controllers/MonitorAlarmCtrl.js']);
                            }]
                    }
                })

                .state('paas.createInstance', {
                    url: '/createInstance',
                    templateUrl: 'tpl/paas/createInstance.html',
                    controller:'CreateInstanceCtrl',
                    resolve: {
                        deps: ['$ocLazyLoad',
                            function( $ocLazyLoad){
                                return $ocLazyLoad.load(['js/controllers/CreateInstanceCtrl.js']);
                            }]
                    }
                })

                .state('paas.editInstance', {
                    url: '/editInstance',
                    templateUrl: 'tpl/paas/editInstance.html',
                    controller:'EditInstanceCtrl',
                    resolve: {
                        deps: ['$ocLazyLoad',
                            function( $ocLazyLoad){
                                return $ocLazyLoad.load(['js/controllers/EditInstanceCtrl.js']);
                            }]
                    }
                })


                .state('paas.authorize', {
                    url: '/authorize',
                    templateUrl: 'tpl/paas/authorize.html',
                    controller:'AuthorizeCtrl',
                    resolve: {
                        deps: ['$ocLazyLoad',
                            function( $ocLazyLoad){
                                return $ocLazyLoad.load(['js/controllers/AuthorizeCtrl.js']);
                            }]
                    }
                })


                .state('paas.redis', {
                    url: '/redis',
                    templateUrl: 'tpl/paas/paas_redis.html',
                    controller:'PaasRedisCtrl',
                    resolve: {
                        deps: ['$ocLazyLoad',
                            function( $ocLazyLoad){
                                return $ocLazyLoad.load(['js/controllers/PaasRedisCtrl.js','js/controllers/test.js']);
                            }]
                    }
                })

                .state('paas.redisDetail', {
                    url: '/redisDetail/:redisName',
                    templateUrl: 'tpl/redisDetail.html'
                })


                .state('paas.zookeeper', {
                    url: '/zookeeper',
                    templateUrl: 'tpl/zookeeperDemo.html',
                    controller:'PaasZooKeeperCtrl',
                    resolve: {
                        deps: ['$ocLazyLoad',
                            function( $ocLazyLoad){
                                return $ocLazyLoad.load(['js/controllers/PaasZooKeeperCtrl.js']);
                            }]
                    }
                })

                .state('paas.zookeeper.basicInfo', {
                    url: '/basicInfo',
                    templateUrl: 'tpl/paas/basicInfo.html',
                    controller:'BasicInfoCtrl',
                    resolve: {
                        deps: ['$ocLazyLoad',
                            function( $ocLazyLoad){
                                return $ocLazyLoad.load(['js/controllers/BasicInfoCtrl.js']);
                            }]
                    }
                })



                //截止

                .state('paas.profile', {
                    url: '/profile',
                    templateUrl: 'tpl/page_profile.html'
                })

                .state('paas.docs', {
                    url: '/docs',
                    templateUrl: 'tpl/docs.html'
                })
        }
    ]
);





